import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
    { meta: { title: '首页' }, path: '/', name: 'main', component: () => import('../views/main.vue') },
    { meta: { title: '车流看板' }, path: '/yzTraffic', name: 'yzTraffic', component: () => import('../views/yzTraffic.vue') },
    { meta: { title: '客流看板' }, path: '/yzClientFlow', name: 'yzClientFlow', component: () => import('../views/yzClientFlow.vue') },
    { meta: { title: '停车看板' }, path: '/parking', name: 'parking', component: () => import('../views/parking.vue') },
    { meta: { title: '停车看板' }, path: '/parking_shanhaiguan', name: 'parking_shanhaiguan', component: () => import('../views/parking_shanhaiguan.vue') },
    { meta: { title: '停车看板' }, path: '/parking_xianghe', name: 'parking_xianghe', component: () => import('../views/parking_xianghe.vue') },
    { meta: { title: '销售看板' }, path: '/yzSale', name: 'yzSale', component: () => import('../views/yzSale.vue') },
    { meta: { title: '厕所看板' }, path: '/toilet', name: 'toilet', component: () => import('../views/toilet.vue') },
    { meta: { title: '安全态势' }, path: '/securitySituation', name: 'securitySituation', component: () => import('../views/securitySituation.vue') },
    { meta: { title: '能耗看板' }, path: '/energy', name: 'energy', component: () => import('../views/energy.vue') },
    { meta: { title: '综合看板' }, path: '/headquarters', name: 'headquarters', component: () => import('../views/headquarters.vue') },
    { meta: { title: '综合看板' }, path: '/headquartersServer', name: 'headquartersServer', component: () => import('../views/headquartersServer.vue') },
    { meta: { title: '基础信息看板' }, path: '/basePanel', name: 'basePanel', component: () => import('../views/basePanel.vue') },
    { meta: { title: '基础信息看板' }, path: '/basePanel2', name: 'basePanel2', component: () => import('../views/basePanel2.vue') },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    document.title = to.meta && to.meta.title ? to.meta.title : '默认标题';
    next();
})

export default router
